﻿using System;
using System.Numerics;

namespace MyThirdCSharp
{
    internal class Program
    {
    /// <summary>
    /// 字符小游戏
    /// </summary>
    /// <param name="args"></param>
        static void Main(string[] args)
        {
            //the introduction
            Console.Write("hello!");
            Console.Write("点击空格来结束程序");
            //set the line and column
            int rank = 0, column = 0;
            Console.SetCursorPosition(rank, column);
            //to circulate
            var input = Console.ReadKey().KeyChar;
            while(input!=' ')
            {  
                //clear the screen
                Console.Clear();
                switch (input)
                {
                    //shift left
                    case 'a':
                    case 'A':
                        {
                            if (--rank < 0)
                                rank = 0;
                            Console.SetCursorPosition(rank, column);
                            Console.WriteLine("hello");
                            break;
                        }
                    //move down
                    case 's':
                    case 'S':
                        {
                            if (++column < 0)
                                column = 0;
                            Console.SetCursorPosition(rank, column);
                            Console.WriteLine("hello");
                            break;
                        }
                    //shift right
                    case 'd':
                    case 'D':
                        {
                            if (++rank < 0)
                                rank = 0;
                            Console.SetCursorPosition(rank, column);
                            Console.WriteLine("hello");
                            break;
                        }
                    //move up
                    case 'w':
                    case 'W':
                        {
                            if (--column < 0)
                                column = 0;
                            Console.SetCursorPosition(rank, column);
                            Console.WriteLine("hello");
                            break;
                        }
                    default:
                        break;
                }
                input = Console.ReadKey().KeyChar;
            } 
        }
    }
}